﻿Imports extranet.BC
Imports extranet.BE
Imports MetodosComuns
Partial Class ranking_AdmRnkListarRankings
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        '==================       PROCEDIMENTO  PADRÃO  SEGURANÇA     =============================
        Dim objBESeguranca As BESeguranca
        Dim objBEUsuario As BEUsuario = Session("objBEUsuario")
        If IsNothing(objBEUsuario) Then Response.Redirect(TELA_LOGOUT)
        Session("strTela") = MetodosComuns.GetCurrentPageName()
        If Not IsPostBack Then          ' SEGURANÇA
            objBESeguranca = BCSeguranca.SelecionaPermissoes(objBEUsuario.GrupoAcesso, Session("strTela"))
            If Not objBESeguranca.Autorizado Then Response.Redirect(TELA_LOGOUT)
            Session("objBESeguranca") = objBESeguranca
        Else
            objBESeguranca = Session("objBESeguranca")
        End If

        If Not IsPostBack Then
            grvRankings.DataSource = BCRanking.ListarRanking(True)
            grvRankings.DataBind()
        End If
    End Sub

    Protected Sub btnRanking_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRanking.Click
        Response.Redirect("AdmRnkGerenciamentoRanking.aspx")
    End Sub

    Protected Sub grvRankings_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grvRankings.RowEditing
        Response.Redirect("AdmRnkGerenciamentoRanking.aspx?Ranking=" & grvRankings.DataKeys(e.NewEditIndex).Value.ToString())
    End Sub

    Protected Sub btnMediar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMediar.Click
        Response.Redirect("AdmRnkMediarMensagens.aspx")
    End Sub

    Protected Sub rblStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rblStatus.SelectedIndexChanged
        Select Case rblStatus.SelectedValue
            Case "Ativos"
                grvRankings.DataSource = BCRanking.ListarRanking(True)
            Case "Todos"
                grvRankings.DataSource = BCRanking.ListarRanking(False)
        End Select
        grvRankings.DataBind()
    End Sub
End Class
